// 引入全部的自定义全局组件
import SvgIcon from './SvgIcon/index.vue'
import TallLoading from './TallLoading/index.vue'
import Category from './Category/index.vue'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 全局对象
const globalComponents: any = {
  SvgIcon,
  TallLoading,
  Category,
}
// 对外暴露插件对象
export default {
  // 方法必须是 install
  install(app: any) {
    // 注册项目全部的全局组件
    Object.keys(globalComponents).forEach((key) => {
      // 注册成为全局组件
      app.component(key, globalComponents[key])
    })
    // 注册所有图标
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
  },
}
